package com.health.userbackstage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.health.userbackstage.mapper.CheckGroupMapper;
import com.health.userbackstage.mapper.CheckItemMapper;
import com.health.userbackstage.pojo.CheckGroup;
import com.health.userbackstage.pojo.CheckItem;
import com.health.userbackstage.service.CheckGroupService;
import com.health.userbackstage.service.CheckItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CheckItemServiceImpl extends ServiceImpl<CheckItemMapper, CheckItem> implements CheckItemService {

    @Autowired
    private CheckItemMapper checkItemMapper;

    public List<CheckItem> findAll(){
        return checkItemMapper.findAll();
    }

    public int update(CheckItem checkItem) {
        return checkItemMapper.updateById(checkItem);
    }

    public int add(CheckItem checkItem) {
        return checkItemMapper.insert(checkItem);
    }

    public int del(Integer id) {
        return checkItemMapper.deleteById(id);
    }


    public List<Integer> findcgid(Integer ciid) {
        return checkItemMapper.findCgid(ciid);
    }

    @Override
    public CheckItem selectOneByCode(CheckItem checkItem) {
        return checkItemMapper.selectOneByCode(checkItem);
    }

    @Override
    public CheckItem selectOneByName(CheckItem checkItem) {
        return checkItemMapper.selectOneByName(checkItem);
    }

    //分页查询
    public PageInfo<CheckItem> findPage(int pageNum, int pageSize){

        PageHelper.startPage(pageNum,pageSize);

        List<CheckItem> id = checkItemMapper.findAll();

        return new PageInfo<>(id);
    }
}
